<template>
  <view id="login">
      <view class="welcome">
          <view>欢迎回来！</view>
          <view>请输入您的工作账号以登录系统</view>
      </view>

      <view class="inputBox">
          <input type="text" v-model="user" placeholder="工作账号">
          <input type="password" v-model="pass" placeholder="密码">
      </view>
      <view class="loginBox">
          <view @click="login">登录</view>
          <view>若忘记密码请联系管理员</view>
      </view>
  </view>
</template>

<script>
export default {
    data(){
        return{
            user:"",
            pass:""
        }
    },
    methods:{
        login(){
            if(!this.user){
                uni.showToast({
                    title: '请输入工作账号',
                    duration: 1000,
                    icon:'none'
                });
                return false
            }
            if(!this.pass){
                uni.showToast({
                    title: '请输入密码',
                    duration: 1000,
                    icon:'none'
                });
                return false
            }
            this.$store.dispatch("login",{account:this.user,password:this.pass}).then(res=>{
                if(res.code==1){
                    // uni.reLaunch({
                    //     url: '/pages/index/index'
                    // });  
                    uni.switchTab({
                        url: '/pages/index/index'
                    });
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>
#login{
    padding: 100rpx 40rpx;
    .welcome{
        view{
            &:nth-of-type(1){
                font-size: 52rpx;
                color: #262e34;
            }
            &:nth-of-type(2){
                font-size: 24rpx;
                color: #a4a8b7;
            }
        }
    }
    .inputBox{
        text-align: center;
        padding: 60rpx;
        margin-top: 100rpx;
        input{
            text-align: left;
            line-height: 80rpx;
            border-bottom: 1px solid #979797;
            margin-bottom: 40rpx;
            font-size: 24rpx;
            padding:20rpx 10rpx;
        }
    }
    .loginBox{
        text-align: center;
        padding: 60rpx;
        margin-top: 100rpx;
        view{
            &:nth-of-type(1){
                background: #0077ff;
                color: #fff;
                text-align: center;
                width: 100%;
                line-height: 80rpx;
                font-size: 32rpx;
                border-radius: 10rpx;
            }
            &:nth-of-type(2){
                font-size: 24rpx;
                color: #a4a8b7;
                margin-top: 20rpx;
            }
        }
    }
}
</style>